package com.ruoyi.web.controller.admin;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.dto.BdmMemberRuleDto;
import com.ruoyi.system.domain.vo.BdmMemberRuleVo;
import com.ruoyi.system.service.IBdmOrderService;
import com.ruoyi.system.service.IBdmUserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;



@Api(tags = "后台-数据")
@RestController
@RequestMapping("/admin/userData")
public class BdmUserDataController extends BaseController {


    @Autowired
    private IBdmUserService iBdmUserService;

    @Autowired
    private IBdmOrderService iBdmOrderService;

    /**
     * 查询会员数据
     *
     * @param dto
     * @return {@link BdmMemberRuleVo}
     */
    @GetMapping("/selectMemberDataPage")
    public TableDataInfo selectPage(BdmMemberRuleDto dto) {
        startPage();
        List<BdmMemberRuleVo> list = iBdmUserService.selectMemberDataPage(dto);
        return getDataTable(list);
    }


    /**
     * 销售数据 总成交
     *
     * @param dto
     * @return
     */
    @GetMapping("/countMarketData")
    public AjaxResult countMarketData(BdmMemberRuleDto dto) {
        return success(iBdmOrderService.countMarketData(dto));
    }

    /**
     * 销售数据 当日成交
     *
     * @param dto
     * @return
     */
    @GetMapping("/todayMarketData")
    public AjaxResult todayMarketData(BdmMemberRuleDto dto) {
        String date = LocalDate.now().toString();
        dto.setCreateStartTime(date);
        dto.setCreateEndTime(date);
        return success(iBdmOrderService.countMarketData(dto));
    }

    /**
     * 销售数据成交订单时间列表
     *
     * @return
     */
    @GetMapping("/selectMarketOrderData")
    public TableDataInfo selectMarketOrderData(BdmMemberRuleDto dto) {
        startPage();
        return getDataTable(iBdmOrderService.selectMarketOrderData(dto));
    }

    /**
     * 数据概况 用户数 订单数 商品数 统计
     *
     * @return
     */
    @GetMapping("/selectUserNumberAndOrderNumberProductNumber")
    public AjaxResult selectUserNumberAndOrderNumberProductNumber(BdmMemberRuleDto dto) {
        return success(iBdmOrderService.selectUserNumberAndOrderNumberProductNumber(dto));
    }

    /**
     * 数据概况 销售情况
     *
     * @param dto
     * @return
     */
    @GetMapping("/marketCondition")
    public AjaxResult marketCondition(BdmMemberRuleDto dto) {
        return success(iBdmOrderService.countMarketData(dto));
    }

    /**
     * 数据概况 商品销售额top前十
     *
     * @return
     */
    @GetMapping("/marketProductTop")
    public AjaxResult marketProductTop() {
        return success(iBdmOrderService.marketProductTop());
    }

    /**
     * 数据概况 用户支付金额top前十
     *
     * @return
     */
    @GetMapping("/userPayMoneyTop")
    public AjaxResult userPayMoneyTop() {
        return success(iBdmOrderService.userPayMoneyTop());
    }

    /**
     * 总裁驾驶窗首页数据
     *
     * @return
     */
    @GetMapping("/bossData")
    public AjaxResult bossData() {
        return success(iBdmOrderService.bossData());
    }
}
